package com.app.teaware.bean;

import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import java.util.ArrayList;

public class BillListBean extends BaseListBean {

    private ArrayList<BillListData> list = new ArrayList<BillListData>();

    public ArrayList<BillListData> getList() {
        return list;
    }

    public void setList(ArrayList<BillListData> list) {
        this.list = list;
    }

    @JSONField(serialize = false)
    public void addListBean(BillListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<BillListData>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }

    public void defaultCheck(){
        for (BillListData data : list){
            data.setCheck(false);
        }
    }

    public void allSelect(){
        for (BillListData data : list){
            data.setCheck(true);
        }
    }

    public BillListBean getCheckBean(){
        BillListBean a = new BillListBean();
        for (BillListData data : list){
            if(data.isCheck()){
                a.getList().add(data);
            }
        }
        return a;
    }

    public ArrayList<String> getCheckRfidList(){
        ArrayList<String> rfidList = new ArrayList<String>();
        for (BillListData data : list){
            if(data.isCheck()){
                rfidList.add(data.getRfid());
            }
        }
        return rfidList;
    }

    public String getCheckRfidString(){
        String str ="";
        for (BillListData data : list){
            if(data.isCheck()){
                str += data.getRfid()+",";
            }
        }
        if(TextUtils.isEmpty(str)) return "";
        return str.substring(0,str.length()-1);
    }
}
